﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Backend.DTO;
using Backend.BLL;
using System.Globalization;

namespace ReSeSSApplication
{
    public partial class OutcomeDetails : System.Web.UI.Page
    {
        protected UserDTO loggedInUserDTO = new UserDTO();
        StudyBLL aStudyBLL = new StudyBLL();
        InclusionOrParameterDTO aInclusionOrParameterDTO = null;
        OutcomeDTO aOutcomeDTO = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            AlertError.Visible = false;
            AlertSuccess.Visible = false;
            AlertInfo.Visible = false;

            loggedInUserDTO = (UserDTO)Session["LoggedInUserDTO"];
            RedirectUser(loggedInUserDTO);

            // checking required session for the page
            if (Session["InclusionOrParameterId"] == null)
            {
                Response.Redirect("NewStudy.aspx");
            }
            else if (Session["OutcomeId"] == null)
            {
                Response.Redirect("Outcomes.aspx");
            }
            else
            {
                InclusionOrParameterIdHiddenField.Value = Session["InclusionOrParameterId"].ToString();
                OutcomeIdHiddenField.Value = Session["OutcomeId"].ToString();

                aInclusionOrParameterDTO = aStudyBLL.GetInclusionOrParameter(Convert.ToInt32(InclusionOrParameterIdHiddenField.Value));
                aOutcomeDTO = aStudyBLL.GetOutcome(Convert.ToInt32(OutcomeIdHiddenField.Value));

                string editOutcomeHeadingText = string.Empty;

                if (aInclusionOrParameterDTO.Type == "Inclusion")
                {
                    editOutcomeHeadingText = "Editing \"" + aInclusionOrParameterDTO.Name + "\" Inclusion";
                }
                else if (aInclusionOrParameterDTO.Type == "Parameter")
                {
                    editOutcomeHeadingText = "Editing \"" + aInclusionOrParameterDTO.Name + "\" Parameter";
                }

                editOutcomeHeadingText += ", Outcome " + aOutcomeDTO.FieldName + " = " + aOutcomeDTO.FieldValue;
                EditOutcomeHeading.InnerText = editOutcomeHeadingText;

                if (string.IsNullOrEmpty(CurrentTabHiddenField.Value))
                {
                    CurrentTabHiddenField.Value = "0";
                }

                LoadGridViews();

                if (!IsPostBack)
                {
                    LoadDropDowns();

                    txtCodeRestrictTimeIntervalFrom.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtCodeRestrictTimeIntervalTo.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtDateTimeIntervalFrom.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtDateTimeIntervalTo.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtReadingsRestrictTimeIntervalFrom.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtReadingsRestrictTimeIntervalTo.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtTextRestrictTimeIntervalFrom.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtTextRestrictTimeIntervalTo.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtRadiologyRestrictTimeIntervalFrom.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtRadiologyRestrictTimeIntervalTo.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtSnomedCtRestrictTimeIntervalFrom.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                    txtSnomedCtRestrictTimeIntervalTo.Text = DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                    txtCodeRestrictTimeIntervalFrom.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtCodeRestrictTimeIntervalTo.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtDateTimeIntervalFrom.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtDateTimeIntervalTo.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtReadingsRestrictTimeIntervalFrom.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtReadingsRestrictTimeIntervalTo.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtTextRestrictTimeIntervalFrom.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtTextRestrictTimeIntervalTo.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtRadiologyRestrictTimeIntervalFrom.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtRadiologyRestrictTimeIntervalTo.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtSnomedCtRestrictTimeIntervalFrom.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                    txtSnomedCtRestrictTimeIntervalTo.Attributes.Add("data-date", DateTime.Now.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));


                    // setup initial page form settings by data stored in the database
                    OutcomeDetailsDTO aOutcomeDetailsDTO = aStudyBLL.GetOutcomeDetails(Convert.ToInt32(OutcomeIdHiddenField.Value));


                    /* Code Specify tab */
                    if (aOutcomeDetailsDTO.CodeType == 1)
                    {
                        rbtnICD10Code.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.CodeType == 2) 
                    {
                        rbtnICD9Code.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.CodeType == 3)
                    {
                        rbtnICD8Code.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.CodeType == 4)
                    {
                        rbtnAGKCode.Checked = true;
                    }

                    CodeIdHiddenField.Value = aOutcomeDetailsDTO.CodeId.ToString();


                    /* Code Restrict tab */
                    if (aOutcomeDetailsDTO.CodeRestrictType == 1)
                    {
                        rbtnCodeRestrictRelated.Checked = true;
                        ddlCodeRestrictRelated.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.CodeRestrictField1);
                    }
                    else if (aOutcomeDetailsDTO.CodeRestrictType == 2)
                    {
                        rbtnCodeRestrictTimeInterval.Checked = true;

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.CodeRestrictField1))
                        {
                            txtCodeRestrictTimeIntervalFrom.Text = aOutcomeDetailsDTO.CodeRestrictField1;
                            txtCodeRestrictTimeIntervalFrom.Attributes.Add("data-date", aOutcomeDetailsDTO.CodeRestrictField1);
                        }

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.CodeRestrictField2))
                        {
                            txtCodeRestrictTimeIntervalTo.Text = aOutcomeDetailsDTO.CodeRestrictField2;
                            txtCodeRestrictTimeIntervalTo.Attributes.Add("data-date", aOutcomeDetailsDTO.CodeRestrictField2);
                        }
                    }
                    else if (aOutcomeDetailsDTO.CodeRestrictType == 3)
                    {
                        rbtnCodeRestrictRestrictBy.Checked = true;
                        ddlCodeRestrictRestrictByFrom.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.CodeRestrictField1);
                        ddlCodeRestrictRestrictByTo.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.CodeRestrictField2);
                    }

                    CodeRestrictField1HiddenField.Value = aOutcomeDetailsDTO.CodeRestrictField1;
                    CodeRestrictField2HiddenField.Value = aOutcomeDetailsDTO.CodeRestrictField2;


                    /* Date/Time tab */
                    if (aOutcomeDetailsDTO.DateType == 1)
                    {
                        rbtnTimeDateParameter.Checked = true;
                        ddlTimeDateParameter.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.DateField1);
                    }
                    else if (aOutcomeDetailsDTO.DateType == 2)
                    {
                        rbtnTimeInterval.Checked = true;

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.DateField1))
                        {
                            txtDateTimeIntervalFrom.Text = aOutcomeDetailsDTO.DateField1;
                            txtDateTimeIntervalFrom.Attributes.Add("data-date", aOutcomeDetailsDTO.DateField1);
                        }

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.DateField2))
                        {
                            txtDateTimeIntervalTo.Text = aOutcomeDetailsDTO.DateField2;
                            txtDateTimeIntervalTo.Attributes.Add("data-date", aOutcomeDetailsDTO.DateField2);
                        }
                    }
                    else if (aOutcomeDetailsDTO.DateType == 3)
                    {
                        rbtnRestrictBy.Checked = true;
                        ddlRestrictByFrom.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.DateField1);
                        ddlRestrictByTo.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.DateField2);
                    }

                    DateField1HiddenField.Value = aOutcomeDetailsDTO.DateField1;
                    DateField2HiddenField.Value = aOutcomeDetailsDTO.DateField2;


                    /* Readings Specify tab */
                    if (aOutcomeDetailsDTO.ReadingsType == 1)
                    {
                        rbtnLaboratory.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.ReadingsType == 2)
                    {
                        rbtnPharmaceuticals.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.ReadingsType == 3)
                    {
                        rbtnMeasurements.Checked = true;
                    }

                    ReadingsIdHiddenField.Value = aOutcomeDetailsDTO.ReadingsId.ToString();


                    /* Readings Restrict tab */
                    if (aOutcomeDetailsDTO.ReadingsRestrictType == 1)
                    {
                        rbtnReadingsRestrictRelated.Checked = true;
                        ddlReadingsRestrictRelated.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.ReadingsRestrictField1);
                    }
                    else if (aOutcomeDetailsDTO.ReadingsRestrictType == 2)
                    {
                        rbtnReadingsRestrictTimeInterval.Checked = true;

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.ReadingsRestrictField1))
                        {
                            txtReadingsRestrictTimeIntervalFrom.Text = aOutcomeDetailsDTO.ReadingsRestrictField1;
                            txtReadingsRestrictTimeIntervalFrom.Attributes.Add("data-date", aOutcomeDetailsDTO.ReadingsRestrictField1);
                            
                        }

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.ReadingsRestrictField2))
                        {
                            txtReadingsRestrictTimeIntervalTo.Text = aOutcomeDetailsDTO.ReadingsRestrictField2;
                            txtReadingsRestrictTimeIntervalTo.Attributes.Add("data-date", aOutcomeDetailsDTO.ReadingsRestrictField2);
                            ReadingsRestrictField2HiddenField.Value = aOutcomeDetailsDTO.ReadingsRestrictField2;
                        }
                    }
                    else if (aOutcomeDetailsDTO.ReadingsRestrictType == 3)
                    {
                        rbtnReadingsRestrictRestrictBy.Checked = true;
                        ddlReadingsRestrictRestrictByFrom.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.ReadingsRestrictField1);
                        ddlReadingsRestrictRestrictByTo.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.ReadingsRestrictField2);
                    }

                    ReadingsRestrictField1HiddenField.Value = aOutcomeDetailsDTO.ReadingsRestrictField1;
                    ReadingsRestrictField2HiddenField.Value = aOutcomeDetailsDTO.ReadingsRestrictField2;


                    /* Text Restrict tab */
                    if (aOutcomeDetailsDTO.TextRestrictType == 1)
                    {
                        rbtnTextRestrictRelated.Checked = true;
                        ddlTextRestrictRelated.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.TextRestrictField1);
                    }
                    else if (aOutcomeDetailsDTO.TextRestrictType == 2)
                    {
                        rbtnTextRestrictTimeInterval.Checked = true;

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.TextRestrictField1))
                        {
                            txtCodeRestrictTimeIntervalFrom.Text = aOutcomeDetailsDTO.TextRestrictField1;
                            txtCodeRestrictTimeIntervalFrom.Attributes.Add("data-date", aOutcomeDetailsDTO.TextRestrictField1);
                        }

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.TextRestrictField2))
                        {
                            txtCodeRestrictTimeIntervalTo.Text = aOutcomeDetailsDTO.TextRestrictField2;
                            txtCodeRestrictTimeIntervalTo.Attributes.Add("data-date", aOutcomeDetailsDTO.TextRestrictField2);
                        }
                    }
                    else if (aOutcomeDetailsDTO.TextRestrictType == 3)
                    {
                        rbtnTextRestrictRestrictBy.Checked = true;
                        ddlCodeRestrictRestrictByFrom.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.TextRestrictField1);
                        ddlCodeRestrictRestrictByTo.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.TextRestrictField2);
                    }

                    TextRestrictField1HiddenField.Value = aOutcomeDetailsDTO.TextRestrictField1;
                    TextRestrictField2HiddenField.Value = aOutcomeDetailsDTO.TextRestrictField2;


                    /* Text tab */
                    if (aOutcomeDetailsDTO.TextType == 1)
                    {
                        rbtnReferrals.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.TextType == 2)
                    {
                        rbtnMedicalFileText.Checked = true;
                    }

                    TextField1HiddenField.Value = aOutcomeDetailsDTO.TextField1;
                    TextField2HiddenField.Value = aOutcomeDetailsDTO.TextField2;
                    TextField3HiddenField.Value = aOutcomeDetailsDTO.TextField3;


                    /* Radiology Specify tab */
                    if (aOutcomeDetailsDTO.RadiologyType == 1)
                    {
                        rbtnMRI.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.RadiologyType == 2)
                    {
                        rbtnCT.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.RadiologyType == 3)
                    {
                        rbtnXRay.Checked = true;
                    }
                    else if (aOutcomeDetailsDTO.RadiologyType == 4)
                    {
                        rbtnUSG.Checked = true;
                    }

                    RadiologyIdHiddenField.Value = aOutcomeDetailsDTO.RadiologyId.ToString();


                    /* Radiology Restrict tab */
                    if (aOutcomeDetailsDTO.RadiologyRestrictType == 1)
                    {
                        rbtnRadiologyRestrictRelated.Checked = true;
                        ddlRadiologyRestrictRelated.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.RadiologyRestrictField1);
                    }
                    else if (aOutcomeDetailsDTO.RadiologyRestrictType == 2)
                    {
                        rbtnRadiologyRestrictTimeInterval.Checked = true;

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.RadiologyRestrictField1))
                        {
                            txtRadiologyRestrictTimeIntervalFrom.Text = aOutcomeDetailsDTO.RadiologyRestrictField1;
                            txtRadiologyRestrictTimeIntervalFrom.Attributes.Add("data-date", aOutcomeDetailsDTO.RadiologyRestrictField1);
                        }

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.RadiologyRestrictField2))
                        {
                            txtRadiologyRestrictTimeIntervalTo.Text = aOutcomeDetailsDTO.RadiologyRestrictField2;
                            txtRadiologyRestrictTimeIntervalTo.Attributes.Add("data-date", aOutcomeDetailsDTO.RadiologyRestrictField2);
                        }
                    }
                    else if (aOutcomeDetailsDTO.RadiologyRestrictType == 3)
                    {
                        rbtnRadiologyRestrictRestrictBy.Checked = true;
                        ddlRadiologyRestrictRestrictByFrom.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.RadiologyRestrictField1);
                        ddlRadiologyRestrictRestrictByTo.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.RadiologyRestrictField2);
                    }

                    RadiologyRestrictField1HiddenField.Value = aOutcomeDetailsDTO.RadiologyRestrictField1;
                    RadiologyRestrictField2HiddenField.Value = aOutcomeDetailsDTO.RadiologyRestrictField2;


                    /* SNOMED-CT tab */
                    if (aOutcomeDetailsDTO.SnomedCtType == 1)
                    {
                        rbtnSnomedCt.Checked = true;
                    }

                    SnomedCtIdHiddenField.Value = aOutcomeDetailsDTO.SnomedCtId.ToString();
                    if (aOutcomeDetailsDTO.SnomedCtId > 0)
                    {
                        GenericListDTO aGenericListDTO = new ListBLL().GetGenericList(aOutcomeDetailsDTO.SnomedCtId);
                        if (aGenericListDTO != null)
                        {
                            
                        }
                    }


                    /* SNOMED-CT Restrict tab */
                    if (aOutcomeDetailsDTO.SnomedCtRestrictType == 1)
                    {
                        rbtnSnomedCtRestrictRelated.Checked = true;
                        ddlSnomedCtRestrictRelated.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.SnomedCtRestrictField1);
                    }
                    else if (aOutcomeDetailsDTO.SnomedCtRestrictType == 2)
                    {
                        rbtnSnomedCtRestrictTimeInterval.Checked = true;

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.SnomedCtRestrictField1))
                        {
                            txtSnomedCtRestrictTimeIntervalFrom.Text = aOutcomeDetailsDTO.SnomedCtRestrictField1;
                            txtSnomedCtRestrictTimeIntervalFrom.Attributes.Add("data-date", aOutcomeDetailsDTO.SnomedCtRestrictField1);
                        }

                        if (!string.IsNullOrEmpty(aOutcomeDetailsDTO.SnomedCtRestrictField2))
                        {
                            txtSnomedCtRestrictTimeIntervalTo.Text = aOutcomeDetailsDTO.SnomedCtRestrictField2;
                            txtSnomedCtRestrictTimeIntervalTo.Attributes.Add("data-date", aOutcomeDetailsDTO.SnomedCtRestrictField2);
                        }
                    }
                    else if (aOutcomeDetailsDTO.SnomedCtRestrictType == 3)
                    {
                        rbtnSnomedCtRestrictRestrictBy.Checked = true;
                        ddlSnomedCtRestrictRestrictByFrom.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.SnomedCtRestrictField1);
                        ddlSnomedCtRestrictRestrictByTo.SelectedIndex = Convert.ToInt32(aOutcomeDetailsDTO.SnomedCtRestrictField2);
                    }

                    SnomedCtField1HiddenField.Value = aOutcomeDetailsDTO.SnomedCtRestrictField1;
                    SnomedCtField2HiddenField.Value = aOutcomeDetailsDTO.SnomedCtRestrictField2;
                }
            }
        }

        protected void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                OutcomeDetailsDTO aOutcomeDetailsDTO = MakeOutcomeDetailsDtoFromUserInput();
                aStudyBLL.UpdateOutcomeDetails(aOutcomeDetailsDTO);

                AlertSuccess.InnerText = "Outcome Details saved successfully.";
                AlertSuccess.Visible = true;
            }
            catch (Exception ex)
            {
                AlertError.InnerText = ex.Message;
                AlertError.Visible = true;
            }
        }

        private OutcomeDetailsDTO MakeOutcomeDetailsDtoFromUserInput()
        {
            OutcomeDetailsDTO aOutcomeDetailsDTO = new OutcomeDetailsDTO();

            // gather OutcomeId
            int outcomeId = Convert.ToInt32(OutcomeIdHiddenField.Value);
            aOutcomeDetailsDTO.OutcomeId = outcomeId;


            // get CodeType
            int codeType = 0;

            if (rbtnICD10Code.Checked)
            {
                codeType = 1;
            }
            else if (rbtnICD9Code.Checked)
            {
                codeType = 2;
            }
            else if (rbtnICD8Code.Checked)
            {
                codeType = 3;
            }
            else if (rbtnAGKCode.Checked)
            {
                codeType = 4;
            }

            aOutcomeDetailsDTO.CodeType = codeType;


            // get CodeId
            int codeId = 0;
            try
            {
                codeId = Convert.ToInt32(CodeIdHiddenField.Value);
            }
            catch
            {
                codeId = 0;
            }

            aOutcomeDetailsDTO.CodeId = codeId;


            // get CodeRestrictType
            int codeRestrictType = 0;
            if (rbtnCodeRestrictRelated.Checked)
            {
                codeRestrictType = 1;
            }
            else if (rbtnCodeRestrictTimeInterval.Checked)
            {
                codeRestrictType = 2;
            }
            else if (rbtnCodeRestrictRestrictBy.Checked)
            {
                codeRestrictType = 3;
            }

            aOutcomeDetailsDTO.CodeRestrictType = codeRestrictType;

            aOutcomeDetailsDTO.CodeRestrictField1 = CodeRestrictField1HiddenField.Value;
            aOutcomeDetailsDTO.CodeRestrictField2 = CodeRestrictField2HiddenField.Value;

            if (codeRestrictType == 1)
            {
                aOutcomeDetailsDTO.CodeRestrictField2 = "0";
            }


            // get DateType
            int dateType = 0;
            if (rbtnTimeDateParameter.Checked)
            {
                dateType = 1;
            }
            else if (rbtnTimeInterval.Checked)
            {
                dateType = 2;
            }
            else if (rbtnRestrictBy.Checked)
            {
                dateType = 3;
            }

            aOutcomeDetailsDTO.DateType = dateType;

            aOutcomeDetailsDTO.DateField1 = DateField1HiddenField.Value;
            aOutcomeDetailsDTO.DateField2 = DateField2HiddenField.Value;

            if (dateType == 1)
            {
                aOutcomeDetailsDTO.DateField2 = "0";
            }


            // get ReadingsType
            int readingsType = 0;
            if (rbtnLaboratory.Checked)
            {
                readingsType = 1;
            }
            else if (rbtnPharmaceuticals.Checked)
            {
                readingsType = 2;
            }
            else if (rbtnMeasurements.Checked)
            {
                readingsType = 3;
            }

            aOutcomeDetailsDTO.ReadingsType = readingsType;


            // get ReadingsId
            int readingsId = 0;
            try
            {
                readingsId = Convert.ToInt32(ReadingsIdHiddenField.Value);
            }
            catch
            {
                readingsId = 0;
            }

            aOutcomeDetailsDTO.ReadingsId = readingsId;


            // get ReadingsRestrictType
            int readingsRestrictType = 0;
            if (rbtnReadingsRestrictRelated.Checked)
            {
                readingsRestrictType = 1;
            }
            else if (rbtnReadingsRestrictTimeInterval.Checked)
            {
                readingsRestrictType = 2;
            }
            else if (rbtnReadingsRestrictRestrictBy.Checked)
            {
                readingsRestrictType = 3;
            }

            aOutcomeDetailsDTO.ReadingsRestrictType = readingsRestrictType;

            aOutcomeDetailsDTO.ReadingsRestrictField1 = ReadingsRestrictField1HiddenField.Value;
            aOutcomeDetailsDTO.ReadingsRestrictField2 = ReadingsRestrictField2HiddenField.Value;

            if (readingsRestrictType == 1)
            {
                aOutcomeDetailsDTO.ReadingsRestrictField2 = "0";
            }


            // get TextType
            int textType = 0;
            if (rbtnReferrals.Checked)
            {
                textType = 1;
            }
            else if (rbtnMedicalFileText.Checked)
            {
                textType = 2;
            }

            aOutcomeDetailsDTO.TextType = textType;
            

            // get TextField1, TextField2, TextField3
            aOutcomeDetailsDTO.TextField1 = TextField1HiddenField.Value;
            aOutcomeDetailsDTO.TextField2 = TextField2HiddenField.Value;
            aOutcomeDetailsDTO.TextField3 = TextField3HiddenField.Value;


            // get TextRestrictType
            int textRestrictType = 0;
            if (rbtnTextRestrictRelated.Checked)
            {
                textRestrictType = 1;
            }
            else if (rbtnTextRestrictTimeInterval.Checked)
            {
                textRestrictType = 2;
            }
            else if (rbtnTextRestrictRestrictBy.Checked)
            {
                textRestrictType = 3;
            }

            aOutcomeDetailsDTO.TextRestrictType = textRestrictType;

            aOutcomeDetailsDTO.TextRestrictField1 = TextRestrictField1HiddenField.Value;
            aOutcomeDetailsDTO.TextRestrictField2 = TextRestrictField2HiddenField.Value;

            if (textRestrictType == 1)
            {
                aOutcomeDetailsDTO.TextRestrictField2 = "0";
            }


            // get RadiologyType
            int radiologyType = 0;

            if (rbtnMRI.Checked)
            {
                radiologyType = 1;
            }
            else if (rbtnCT.Checked)
            {
                radiologyType = 2;
            }
            else if (rbtnXRay.Checked)
            {
                radiologyType = 3;
            }
            else if (rbtnUSG.Checked)
            {
                radiologyType = 4;
            }

            aOutcomeDetailsDTO.RadiologyType = radiologyType;


            // get RadiologyId
            int radiologyId = 0;
            try
            {
                radiologyId = Convert.ToInt32(RadiologyIdHiddenField.Value);
            }
            catch
            {
                radiologyId = 0;
            }

            aOutcomeDetailsDTO.RadiologyId = radiologyId;


            // get RadiologyRestrictType
            int radiologyRestrictType = 0;
            if (rbtnRadiologyRestrictRelated.Checked)
            {
                radiologyRestrictType = 1;
            }
            else if (rbtnRadiologyRestrictTimeInterval.Checked)
            {
                radiologyRestrictType = 2;
            }
            else if (rbtnRadiologyRestrictRestrictBy.Checked)
            {
                radiologyRestrictType = 3;
            }

            aOutcomeDetailsDTO.RadiologyRestrictType = radiologyRestrictType;

            aOutcomeDetailsDTO.RadiologyRestrictField1 = RadiologyRestrictField1HiddenField.Value;
            aOutcomeDetailsDTO.RadiologyRestrictField2 = RadiologyRestrictField2HiddenField.Value;

            if (radiologyRestrictType == 1)
            {
                aOutcomeDetailsDTO.RadiologyRestrictField2 = "0";
            }


            // get SnomedCtType
            int snomedCtType = 0;
            if (rbtnSnomedCt.Checked == true)
            {
                snomedCtType = 1;
            }

            aOutcomeDetailsDTO.SnomedCtType = snomedCtType;


            // get SnomedCtId
            int snomedCtCodeId = 0;
            try
            {
                snomedCtCodeId = Convert.ToInt32(SnomedCtIdHiddenField.Value);
            }
            catch
            {
                snomedCtCodeId = 0;
            }

            aOutcomeDetailsDTO.SnomedCtId = snomedCtCodeId;


            // get SnomedCtRestrictType
            int snomedCtRestrictType = 0;
            if (rbtnSnomedCtRestrictRelated.Checked)
            {
                snomedCtRestrictType = 1;
            }
            else if (rbtnSnomedCtRestrictTimeInterval.Checked)
            {
                snomedCtRestrictType = 2;
            }
            else if (rbtnSnomedCtRestrictRestrictBy.Checked)
            {
                snomedCtRestrictType = 3;
            }

            aOutcomeDetailsDTO.SnomedCtRestrictType = snomedCtRestrictType;

            aOutcomeDetailsDTO.SnomedCtRestrictField1 = SnomedCtField1HiddenField.Value;
            aOutcomeDetailsDTO.SnomedCtRestrictField2 = SnomedCtField2HiddenField.Value;


            return aOutcomeDetailsDTO;
        }

        #region GridView PreRender Event
        protected void ICD10ListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                ICD10ListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void ICD9ListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                ICD9ListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void ICD8ListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                ICD8ListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void AGKListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                AGKListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void LaboratoryListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                LaboratoryListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void PharmaceuticalsListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                PharmaceuticalsListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void MeasurementsListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                MeasurementsListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void MRIListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                MRIListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void CTListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                CTListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void XRayListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                XRayListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void USGListGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                USGListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected void SnomedCtGridView_PreRender(object sender, EventArgs e)
        {
            try
            {
                SnomedCtGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }
        #endregion

        private void LoadGridViews()
        {
            ListBLL aListBll = new ListBLL();

            // Load ICD10ListGridView
            ICD10ListGridView.DataSource = aListBll.GetGenericLists(1);
            ICD10ListGridView.DataBind();

            // Load ICD9ListGridView
            ICD9ListGridView.DataSource = aListBll.GetGenericLists(2);
            ICD9ListGridView.DataBind();

            // Load ICD8ListGridView
            ICD8ListGridView.DataSource = aListBll.GetGenericLists(3);
            ICD8ListGridView.DataBind();

            // Load AGKListGridView
            AGKListGridView.DataSource = aListBll.GetGenericLists(4);
            AGKListGridView.DataBind();

            // Load LaboratoryListGridView
            LaboratoryListGridView.DataSource = aListBll.GetGenericLists(5);
            LaboratoryListGridView.DataBind();

            // Load PharmaceuticalsListGridView
            PharmaceuticalsListGridView.DataSource = aListBll.GetPharmaceuticalLists();
            PharmaceuticalsListGridView.DataBind();

            // Load MeasurementsListGridView
            MeasurementsListGridView.DataSource = aListBll.GetGenericLists(6);
            MeasurementsListGridView.DataBind();

            // Load MRIListGridView
            MRIListGridView.DataSource = aListBll.GetGenericLists(7);
            MRIListGridView.DataBind();

            // Load CTListGridView
            CTListGridView.DataSource = aListBll.GetGenericLists(8);
            CTListGridView.DataBind();

            // Load XRayListGridView
            XRayListGridView.DataSource = aListBll.GetGenericLists(9);
            XRayListGridView.DataBind();

            // Load USGListGridView
            USGListGridView.DataSource = aListBll.GetGenericLists(10);
            USGListGridView.DataBind();

            // Load SnomedCtGridView
            SnomedCtGridView.DataSource = aListBll.GetGenericLists(11);
            SnomedCtGridView.DataBind();
        }

        private void LoadDropDowns()
        {
            // populate ddlCodeRestrictRelated DropDown
            ddlCodeRestrictRelated.Items.Add(new ListItem("Select an item", "0"));
            ddlCodeRestrictRelated.Items.Add(new ListItem("Admission Date", "1"));
            ddlCodeRestrictRelated.Items.Add(new ListItem("Discharge Date", "2"));
            ddlCodeRestrictRelated.Items.Add(new ListItem("Visiting Date", "3"));
            ddlCodeRestrictRelated.Items.Add(new ListItem("Date of Birth", "4"));
            ddlCodeRestrictRelated.Items.Add(new ListItem("Date of Death", "5"));
            ddlCodeRestrictRelated.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlCodeRestrictRestrictByFrom DropDown
            ddlCodeRestrictRestrictByFrom.Items.Add(new ListItem("Select an item", "0"));
            ddlCodeRestrictRestrictByFrom.Items.Add(new ListItem("Admission Date", "1"));
            ddlCodeRestrictRestrictByFrom.Items.Add(new ListItem("Discharge Date", "2"));
            ddlCodeRestrictRestrictByFrom.Items.Add(new ListItem("Visiting Date", "3"));
            ddlCodeRestrictRestrictByFrom.Items.Add(new ListItem("Date of Birth", "4"));
            ddlCodeRestrictRestrictByFrom.Items.Add(new ListItem("Date of Death", "5"));
            ddlCodeRestrictRestrictByFrom.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlCodeRestrictRestrictByTo DropDown
            ddlCodeRestrictRestrictByTo.Items.Add(new ListItem("Select an item", "0"));
            ddlCodeRestrictRestrictByTo.Items.Add(new ListItem("Admission Date", "1"));
            ddlCodeRestrictRestrictByTo.Items.Add(new ListItem("Discharge Date", "2"));
            ddlCodeRestrictRestrictByTo.Items.Add(new ListItem("Visiting Date", "3"));
            ddlCodeRestrictRestrictByTo.Items.Add(new ListItem("Date of Birth", "4"));
            ddlCodeRestrictRestrictByTo.Items.Add(new ListItem("Date of Death", "5"));
            ddlCodeRestrictRestrictByTo.Items.Add(new ListItem("Parameter", "6"));

            // populate ddlTimeDateParameter DropDown
            ddlTimeDateParameter.Items.Add(new ListItem("Select an item", "0"));
            ddlTimeDateParameter.Items.Add(new ListItem("Admission Date", "1"));
            ddlTimeDateParameter.Items.Add(new ListItem("Discharge Date", "2"));
            ddlTimeDateParameter.Items.Add(new ListItem("Visiting Date", "3"));
            ddlTimeDateParameter.Items.Add(new ListItem("Date of Birth", "4"));
            ddlTimeDateParameter.Items.Add(new ListItem("Date of Death", "5"));
            ddlTimeDateParameter.Items.Add(new ListItem("Age", "6"));
            ddlTimeDateParameter.Items.Add(new ListItem("Parameter", "7"));
            // populate ddlRestrictByFrom DropDown
            ddlRestrictByFrom.Items.Add(new ListItem("Select an item", "0"));
            ddlRestrictByFrom.Items.Add(new ListItem("Admission Date", "1"));
            ddlRestrictByFrom.Items.Add(new ListItem("Discharge Date", "2"));
            ddlRestrictByFrom.Items.Add(new ListItem("Visiting Date", "3"));
            ddlRestrictByFrom.Items.Add(new ListItem("Date of Birth", "4"));
            ddlRestrictByFrom.Items.Add(new ListItem("Date of Death", "5"));
            ddlRestrictByFrom.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlRestrictByTo DropDown
            ddlRestrictByTo.Items.Add(new ListItem("Select an item", "0"));
            ddlRestrictByTo.Items.Add(new ListItem("Admission Date", "1"));
            ddlRestrictByTo.Items.Add(new ListItem("Discharge Date", "2"));
            ddlRestrictByTo.Items.Add(new ListItem("Visiting Date", "3"));
            ddlRestrictByTo.Items.Add(new ListItem("Date of Birth", "4"));
            ddlRestrictByTo.Items.Add(new ListItem("Date of Death", "5"));
            ddlRestrictByTo.Items.Add(new ListItem("Parameter", "6"));

            // populate ddlReadingsRestrictRelated DropDown
            ddlReadingsRestrictRelated.Items.Add(new ListItem("Select an item", "0"));
            ddlReadingsRestrictRelated.Items.Add(new ListItem("Admission Date", "1"));
            ddlReadingsRestrictRelated.Items.Add(new ListItem("Discharge Date", "2"));
            ddlReadingsRestrictRelated.Items.Add(new ListItem("Visiting Date", "3"));
            ddlReadingsRestrictRelated.Items.Add(new ListItem("Date of Birth", "4"));
            ddlReadingsRestrictRelated.Items.Add(new ListItem("Date of Death", "5"));
            ddlReadingsRestrictRelated.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlReadingsRestrictRestrictByFrom DropDown
            ddlReadingsRestrictRestrictByFrom.Items.Add(new ListItem("Select an item", "0"));
            ddlReadingsRestrictRestrictByFrom.Items.Add(new ListItem("Admission Date", "1"));
            ddlReadingsRestrictRestrictByFrom.Items.Add(new ListItem("Discharge Date", "2"));
            ddlReadingsRestrictRestrictByFrom.Items.Add(new ListItem("Visiting Date", "3"));
            ddlReadingsRestrictRestrictByFrom.Items.Add(new ListItem("Date of Birth", "4"));
            ddlReadingsRestrictRestrictByFrom.Items.Add(new ListItem("Date of Death", "5"));
            ddlReadingsRestrictRestrictByFrom.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlReadingsRestrictRestrictByTo DropDown
            ddlReadingsRestrictRestrictByTo.Items.Add(new ListItem("Select an item", "0"));
            ddlReadingsRestrictRestrictByTo.Items.Add(new ListItem("Admission Date", "1"));
            ddlReadingsRestrictRestrictByTo.Items.Add(new ListItem("Discharge Date", "2"));
            ddlReadingsRestrictRestrictByTo.Items.Add(new ListItem("Visiting Date", "3"));
            ddlReadingsRestrictRestrictByTo.Items.Add(new ListItem("Date of Birth", "4"));
            ddlReadingsRestrictRestrictByTo.Items.Add(new ListItem("Date of Death", "5"));
            ddlReadingsRestrictRestrictByTo.Items.Add(new ListItem("Parameter", "6"));

            // populate ddlReferralsProfession DropDown
            ddlReferralsProfession.Items.Add(new ListItem("Select an item", "0"));
            ddlReferralsProfession.Items.Add(new ListItem("Microbiology", "1"));
            ddlReferralsProfession.Items.Add(new ListItem("Pharmacology", "2"));
            ddlReferralsProfession.Items.Add(new ListItem("Transfusion", "3"));
            ddlReferralsProfession.Items.Add(new ListItem("Cytology", "4"));
            ddlReferralsProfession.Items.Add(new ListItem("Neurophysiology", "5"));
            ddlReferralsProfession.Items.Add(new ListItem("Radiology", "6"));
            ddlReferralsProfession.Items.Add(new ListItem("Physiology", "7"));
            ddlReferralsProfession.Items.Add(new ListItem("Immunology", "8"));

            // populate ddlReferralsType DropDown
            ddlReferralsType.Items.Add(new ListItem("Select an item", "0"));
            ddlReferralsType.Items.Add(new ListItem("Emergent", "1"));
            ddlReferralsType.Items.Add(new ListItem("Non-emergent", "2"));

            // populate ddlReferralsDepartment DropDown
            ddlReferralsDepartment.Items.Add(new ListItem("Select an item", "0"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Anesthesiology, Operations and Intensive Care", "1"));
            ddlReferralsDepartment.Items.Add(new ListItem("Child", "2"));
            ddlReferralsDepartment.Items.Add(new ListItem("Breast and Endokrinkirurgiska clinic", "3"));
            ddlReferralsDepartment.Items.Add(new ListItem("CAST", "4"));
            ddlReferralsDepartment.Items.Add(new ListItem("ECMO center", "5"));
            ddlReferralsDepartment.Items.Add(new ListItem("Endokrinmedicinska clinic", "6"));
            ddlReferralsDepartment.Items.Add(new ListItem("Gastro Center Surgery", "7"));
            ddlReferralsDepartment.Items.Add(new ListItem("Gastro Center Medicine", "8"));
            ddlReferralsDepartment.Items.Add(new ListItem("Geriatric Clinic", "9"));
            ddlReferralsDepartment.Items.Add(new ListItem("Hematology", "10"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Cardiology", "11"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Dermatology", "12"));
            ddlReferralsDepartment.Items.Add(new ListItem("Hyperbarmedicin - Pressure vessels", "13"));
            ddlReferralsDepartment.Items.Add(new ListItem("Hearing and Balance Clinic", "14"));
            ddlReferralsDepartment.Items.Add(new ListItem("Immunodeficiency Unit", "15"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Infectious Diseases", "16"));
            ddlReferralsDepartment.Items.Add(new ListItem("Obstetrics and Gynecology", "17"));
            ddlReferralsDepartment.Items.Add(new ListItem("Vascular Surgery", "18"));
            ddlReferralsDepartment.Items.Add(new ListItem("Speech Therapy Clinic", "19"));
            ddlReferralsDepartment.Items.Add(new ListItem("Pulmonary-Allergy Clinic", "20"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Neurosurgery", "21"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Neurology", "22"));
            ddlReferralsDepartment.Items.Add(new ListItem("Renal Medicine", "23"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Oncology", "24"));
            ddlReferralsDepartment.Items.Add(new ListItem("Orthopaedic Surgery", "25"));
            ddlReferralsDepartment.Items.Add(new ListItem("Psykologklinien", "26"));
            ddlReferralsDepartment.Items.Add(new ListItem("Reconstructive plastic surgery", "27"));
            ddlReferralsDepartment.Items.Add(new ListItem("Rheumatology Clinic", "28"));
            ddlReferralsDepartment.Items.Add(new ListItem("Social Medicine", "29"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Thoracic Surgery", "30"));
            ddlReferralsDepartment.Items.Add(new ListItem("Transplant Surgery", "31"));
            ddlReferralsDepartment.Items.Add(new ListItem("Department of Urology", "32"));
            ddlReferralsDepartment.Items.Add(new ListItem("Ear, Nose and Throat Clinic", "33"));

            // populate ddlMFTProfession DropDown
            ddlMFTProfession.Items.Add(new ListItem("Select an item", "0"));
            ddlMFTProfession.Items.Add(new ListItem("Doctor", "1"));
            ddlMFTProfession.Items.Add(new ListItem("Nurse", "2"));
            ddlMFTProfession.Items.Add(new ListItem("Assistance", "3"));

            // populate ddlMFTType DropDown
            ddlMFTType.Items.Add(new ListItem("Select an item", "0"));
            ddlMFTType.Items.Add(new ListItem("Emergency Note", "1"));
            ddlMFTType.Items.Add(new ListItem("Admission Note", "2"));
            ddlMFTType.Items.Add(new ListItem("Daily Note", "3"));
            ddlMFTType.Items.Add(new ListItem("Discharge Note", "4"));
            ddlMFTType.Items.Add(new ListItem("Surgical Story", "5"));

            // populate ddlMFTDepartment DropDown
            ddlMFTDepartment.Items.Add(new ListItem("Select an item", "0"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Anesthesiology, Operations and Intensive Care", "1"));
            ddlMFTDepartment.Items.Add(new ListItem("Child", "2"));
            ddlMFTDepartment.Items.Add(new ListItem("Breast and Endokrinkirurgiska clinic", "3"));
            ddlMFTDepartment.Items.Add(new ListItem("CAST", "4"));
            ddlMFTDepartment.Items.Add(new ListItem("ECMO center", "5"));
            ddlMFTDepartment.Items.Add(new ListItem("Endokrinmedicinska clinic", "6"));
            ddlMFTDepartment.Items.Add(new ListItem("Gastro Center Surgery", "7"));
            ddlMFTDepartment.Items.Add(new ListItem("Gastro Center Medicine", "8"));
            ddlMFTDepartment.Items.Add(new ListItem("Geriatric Clinic", "9"));
            ddlMFTDepartment.Items.Add(new ListItem("Hematology", "10"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Cardiology", "11"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Dermatology", "12"));
            ddlMFTDepartment.Items.Add(new ListItem("Hyperbarmedicin - Pressure vessels", "13"));
            ddlMFTDepartment.Items.Add(new ListItem("Hearing and Balance Clinic", "14"));
            ddlMFTDepartment.Items.Add(new ListItem("Immunodeficiency Unit", "15"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Infectious Diseases", "16"));
            ddlMFTDepartment.Items.Add(new ListItem("Obstetrics and Gynecology", "17"));
            ddlMFTDepartment.Items.Add(new ListItem("Vascular Surgery", "18"));
            ddlMFTDepartment.Items.Add(new ListItem("Speech Therapy Clinic", "19"));
            ddlMFTDepartment.Items.Add(new ListItem("Pulmonary-Allergy Clinic", "20"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Neurosurgery", "21"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Neurology", "22"));
            ddlMFTDepartment.Items.Add(new ListItem("Renal Medicine", "23"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Oncology", "24"));
            ddlMFTDepartment.Items.Add(new ListItem("Orthopaedic Surgery", "25"));
            ddlMFTDepartment.Items.Add(new ListItem("Psykologklinien", "26"));
            ddlMFTDepartment.Items.Add(new ListItem("Reconstructive plastic surgery", "27"));
            ddlMFTDepartment.Items.Add(new ListItem("Rheumatology Clinic", "28"));
            ddlMFTDepartment.Items.Add(new ListItem("Social Medicine", "29"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Thoracic Surgery", "30"));
            ddlMFTDepartment.Items.Add(new ListItem("Transplant Surgery", "31"));
            ddlMFTDepartment.Items.Add(new ListItem("Department of Urology", "32"));
            ddlMFTDepartment.Items.Add(new ListItem("Ear, Nose and Throat Clinic", "33"));

            // populate ddlTextRestrictRelated DropDown
            ddlTextRestrictRelated.Items.Add(new ListItem("Select an item", "0"));
            ddlTextRestrictRelated.Items.Add(new ListItem("Admission Date", "1"));
            ddlTextRestrictRelated.Items.Add(new ListItem("Discharge Date", "2"));
            ddlTextRestrictRelated.Items.Add(new ListItem("Visiting Date", "3"));
            ddlTextRestrictRelated.Items.Add(new ListItem("Date of Birth", "4"));
            ddlTextRestrictRelated.Items.Add(new ListItem("Date of Death", "5"));
            ddlTextRestrictRelated.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlTextRestrictRestrictByFrom DropDown
            ddlTextRestrictRestrictByFrom.Items.Add(new ListItem("Select an item", "0"));
            ddlTextRestrictRestrictByFrom.Items.Add(new ListItem("Admission Date", "1"));
            ddlTextRestrictRestrictByFrom.Items.Add(new ListItem("Discharge Date", "2"));
            ddlTextRestrictRestrictByFrom.Items.Add(new ListItem("Visiting Date", "3"));
            ddlTextRestrictRestrictByFrom.Items.Add(new ListItem("Date of Birth", "4"));
            ddlTextRestrictRestrictByFrom.Items.Add(new ListItem("Date of Death", "5"));
            ddlTextRestrictRestrictByFrom.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlTextRestrictRestrictByTo DropDown
            ddlTextRestrictRestrictByTo.Items.Add(new ListItem("Select an item", "0"));
            ddlTextRestrictRestrictByTo.Items.Add(new ListItem("Admission Date", "1"));
            ddlTextRestrictRestrictByTo.Items.Add(new ListItem("Discharge Date", "2"));
            ddlTextRestrictRestrictByTo.Items.Add(new ListItem("Visiting Date", "3"));
            ddlTextRestrictRestrictByTo.Items.Add(new ListItem("Date of Birth", "4"));
            ddlTextRestrictRestrictByTo.Items.Add(new ListItem("Date of Death", "5"));
            ddlTextRestrictRestrictByTo.Items.Add(new ListItem("Parameter", "6"));

            // populate ddlRadiologyRestrictRelated DropDown
            ddlRadiologyRestrictRelated.Items.Add(new ListItem("Select an item", "0"));
            ddlRadiologyRestrictRelated.Items.Add(new ListItem("Admission Date", "1"));
            ddlRadiologyRestrictRelated.Items.Add(new ListItem("Discharge Date", "2"));
            ddlRadiologyRestrictRelated.Items.Add(new ListItem("Visiting Date", "3"));
            ddlRadiologyRestrictRelated.Items.Add(new ListItem("Date of Birth", "4"));
            ddlRadiologyRestrictRelated.Items.Add(new ListItem("Date of Death", "5"));
            ddlRadiologyRestrictRelated.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlRadiologyRestrictRestrictByFrom DropDown
            ddlRadiologyRestrictRestrictByFrom.Items.Add(new ListItem("Select an item", "0"));
            ddlRadiologyRestrictRestrictByFrom.Items.Add(new ListItem("Admission Date", "1"));
            ddlRadiologyRestrictRestrictByFrom.Items.Add(new ListItem("Discharge Date", "2"));
            ddlRadiologyRestrictRestrictByFrom.Items.Add(new ListItem("Visiting Date", "3"));
            ddlRadiologyRestrictRestrictByFrom.Items.Add(new ListItem("Date of Birth", "4"));
            ddlRadiologyRestrictRestrictByFrom.Items.Add(new ListItem("Date of Death", "5"));
            ddlRadiologyRestrictRestrictByFrom.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlRadiologyRestrictRestrictByTo DropDown
            ddlRadiologyRestrictRestrictByTo.Items.Add(new ListItem("Select an item", "0"));
            ddlRadiologyRestrictRestrictByTo.Items.Add(new ListItem("Admission Date", "1"));
            ddlRadiologyRestrictRestrictByTo.Items.Add(new ListItem("Discharge Date", "2"));
            ddlRadiologyRestrictRestrictByTo.Items.Add(new ListItem("Visiting Date", "3"));
            ddlRadiologyRestrictRestrictByTo.Items.Add(new ListItem("Date of Birth", "4"));
            ddlRadiologyRestrictRestrictByTo.Items.Add(new ListItem("Date of Death", "5"));
            ddlRadiologyRestrictRestrictByTo.Items.Add(new ListItem("Parameter", "6"));

            // populate ddlSnomedCtRestrictRelated DropDown
            ddlSnomedCtRestrictRelated.Items.Add(new ListItem("Select an item", "0"));
            ddlSnomedCtRestrictRelated.Items.Add(new ListItem("Admission Date", "1"));
            ddlSnomedCtRestrictRelated.Items.Add(new ListItem("Discharge Date", "2"));
            ddlSnomedCtRestrictRelated.Items.Add(new ListItem("Visiting Date", "3"));
            ddlSnomedCtRestrictRelated.Items.Add(new ListItem("Date of Birth", "4"));
            ddlSnomedCtRestrictRelated.Items.Add(new ListItem("Date of Death", "5"));
            ddlSnomedCtRestrictRelated.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlSnomedCtRestrictRestrictByFrom DropDown
            ddlSnomedCtRestrictRestrictByFrom.Items.Add(new ListItem("Select an item", "0"));
            ddlSnomedCtRestrictRestrictByFrom.Items.Add(new ListItem("Admission Date", "1"));
            ddlSnomedCtRestrictRestrictByFrom.Items.Add(new ListItem("Discharge Date", "2"));
            ddlSnomedCtRestrictRestrictByFrom.Items.Add(new ListItem("Visiting Date", "3"));
            ddlSnomedCtRestrictRestrictByFrom.Items.Add(new ListItem("Date of Birth", "4"));
            ddlSnomedCtRestrictRestrictByFrom.Items.Add(new ListItem("Date of Death", "5"));
            ddlSnomedCtRestrictRestrictByFrom.Items.Add(new ListItem("Parameter", "6"));
            // populate ddlSnomedCtRestrictRestrictByTo DropDown
            ddlSnomedCtRestrictRestrictByTo.Items.Add(new ListItem("Select an item", "0"));
            ddlSnomedCtRestrictRestrictByTo.Items.Add(new ListItem("Admission Date", "1"));
            ddlSnomedCtRestrictRestrictByTo.Items.Add(new ListItem("Discharge Date", "2"));
            ddlSnomedCtRestrictRestrictByTo.Items.Add(new ListItem("Visiting Date", "3"));
            ddlSnomedCtRestrictRestrictByTo.Items.Add(new ListItem("Date of Birth", "4"));
            ddlSnomedCtRestrictRestrictByTo.Items.Add(new ListItem("Date of Death", "5"));
            ddlSnomedCtRestrictRestrictByTo.Items.Add(new ListItem("Parameter", "6"));
        }

        private void RedirectUser(UserDTO userDTO)
        {
            if (userDTO != null)
            {
                if (userDTO.UserType == "Administrator")
                {
                    Response.Redirect("AdministratorDashboard.aspx");
                }
            }
            else
            {
                Response.Redirect("Index.aspx");
            }
        }
    }
}